<template>

  <el-form ref="form" :rules="rules" :model="formEvent.form" label-width="120px" :size="size"
           :disabled="formEvent.type === 'view' ? true : false">
    <div style="display:flex">
      <!-- {{OptionData.OptionData_yxzt}} -->
      <el-row v-if="showEwm" :gutter="16">
        <!-- 通过调整lg的大�?  12 24/3=12 会变为一�?3�? -->
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="单位" prop="gldwmc">
            <el-select v-model="formEvent.form.gldwbm" style="width:530px;" @change="onchange_gldw">
              <el-option
                v-for="item in OptionData.OptionData_gldw"
                :key="item.value"
                :label="item.label"
                :value="item.value"

              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="物资类别">
            <el-input v-model="formEvent.form.wzlbmc" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="设备类型" prop="sblxmc">
            <!-- <el-input v-model="formEvent.form.sblxmc"></el-input> -->
            <el-select v-model="formEvent.form.sblxbm" @change="onchange_sblx">
              <el-option
                v-for="item in OptionData.OptionData_sblxmc"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="设备名称" prop="sbmc">
            <el-input v-model="formEvent.form.sbmc"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="出厂编码" prop="ccbm">
            <el-input v-model="formEvent.form.ccbm"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="所属库房" prop="sskfmc">
            <!-- 10-未投运
  20-在运
  30-退役
  40-报废 -->
            <el-select v-model="formEvent.form.sskfbm" @change="onchange_sskf">
              <el-option
                v-for="item in OptionData.OptionData_sskfmc"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="规格" prop="sbgg">
            <el-input v-model="formEvent.form.sbgg"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="型号" prop="xh">
            <el-input v-model="formEvent.form.xh"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="计量方式" prop="jlfsmc">
            <el-select v-model="formEvent.form.jlfsmc" @change="onchange_jlfs">
              <el-option
                v-for="item in OptionData.OptionData_jlfs"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="出厂日期" prop="ccrq">
            <!-- <el-input v-model=""></el-input> -->
            <el-date-picker
              style="width:100%"
              v-model="formEvent.form.ccrq"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="运行状态" prop="yxzt">
            <!-- 10-未投运
  20-在运
  30-退役
  40-报废 -->
            <el-select v-model="formEvent.form.yxzt" @change="onchange_yxzt">
              <el-option
                v-for="item in OptionData.OptionData_yxzt"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="投运日期" prop="tyrq">
            <!-- <el-input v-model=""></el-input> -->
            <el-date-picker
              style="width:100%"
              v-model="formEvent.form.tyrq"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="PT" prop="pt">
            <el-input v-model="formEvent.form.pt"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="CT" prop="ct">
            <el-input v-model="formEvent.form.ct"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="是否已检测">
            <!-- 10-未投运
  20-在运
  30-退役
  40-报废 -->
            <el-select v-model="formEvent.form.sfjc">
              <el-option label="是" value="1"></el-option>
              <el-option label="否" value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="厂家" prop="cjmc">
            <el-input v-model="formEvent.form.cjmc"></el-input>
          </el-form-item>
        </el-col>
        <el-col v-if="formEvent.type === 'view'" :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="坐标" prop="sbzb">
            <el-input v-model="formEvent.form.sbzb"></el-input>
          </el-form-item>
        </el-col>
        <el-col v-if="formEvent.type === 'view'" :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="地址" prop="sbdz">
            <el-input v-model="formEvent.form.sbdz"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="创建人" prop="cjr">
            <el-input v-model="formEvent.form.cjr" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col v-if="formEvent.type === 'view'" :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="是否贴签" prop="sftq">
            <el-select v-model="formEvent.form.sftq">
              <el-option label="是" value="1"></el-option>
              <el-option label="否" value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="创建时间" prop="cjtime">
            <el-input v-model="formEvent.form.cjtime" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-if="!showEwm" :gutter="16">
        <!-- 通过调整lg的大�?  12 24/3=12 会变为一�?3�? -->
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="单位" prop="gldwbm">
            <el-select v-model="formEvent.form.gldwbm" style="width:530px;" @change="onchange_gldw">
              <el-option
                v-for="item in OptionData.OptionData_gldw"
                :key="item.value"
                :label="item.label"
                :value="item.value"

              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="物资类别">
            <el-input v-model="formEvent.form.wzlbmc" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="设备类型" prop="sblxbm">
            <!-- <el-input v-model="formEvent.form.sblxmc"></el-input> -->
            <el-select v-model="formEvent.form.sblxbm" @change="onchange_sblx">
              <el-option
                v-for="item in OptionData.OptionData_sblxmc"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="设备名称" prop="sbmc">
            <el-input v-model="formEvent.form.sbmc"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="出厂编码" prop="ccbm">
            <el-input v-model="formEvent.form.ccbm"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="所属能源站" prop="ssjfmc">
            <el-select v-model="formEvent.form.ssjfmc" @change="onchange_ssjf">
              <el-option
                v-for="item in OptionData.OptionData_ssjfmc"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="出厂日期" prop="ccrq">
            <el-date-picker
              style="width:100%"
              v-model="formEvent.form.ccrq"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="厂家">
            <el-input v-model="formEvent.form.cjmc"></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="运行状态" prop="yxzt">
            <el-select v-model="formEvent.form.yxzt" @change="onchange_yxzt">
              <el-option
                v-for="item in OptionData.OptionData_yxzt"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="投运日期" prop="tyrq">
            <el-date-picker
              style="width:100%"
              v-model="formEvent.form.tyrq"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <div v-if="formEvent.form.sblxbm === '200003'">
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="型号" prop="xh">
              <el-input v-model="formEvent.form.xh"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="额定电压(V)" prop="eddy">
              <el-input v-model="formEvent.form.eddy"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="标准" prop="bz">
              <el-input v-model="formEvent.form.bz"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="额定电流(A)" prop="eddl">
              <el-input v-model="formEvent.form.eddl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="频率(HZ)" prop="pl">
              <el-input v-model="formEvent.form.pl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="防护等级" prop="fhdj">
              <el-input v-model="formEvent.form.fhdj"></el-input>
            </el-form-item>
          </el-col>
        </div>
        <div v-if="formEvent.form.sblxbm === '200004'">
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="型号" prop="xh">
              <el-input v-model="formEvent.form.xh"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="Q(m3/h)" prop="q">
              <el-input v-model="formEvent.form.q"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="H(m)" prop="h">
              <el-input v-model="formEvent.form.h"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="n(r/min)" prop="n">
              <el-input v-model="formEvent.form.n"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="Wt.(kg)" prop="wt">
              <el-input v-model="formEvent.form.wt"></el-input>
            </el-form-item>
          </el-col>
        </div>
        <div v-if="formEvent.form.sblxbm === '200005'">
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="标准制冷量(kW)" prop="bzzll">
              <el-input v-model="formEvent.form.bzzll"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="制冷功率(kW)" prop="zlgl">
              <el-input v-model="formEvent.form.zlgl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="标准制热量(kW)" prop="bzzrl">
              <el-input v-model="formEvent.form.bzzrl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="制冷剂" prop="zlj">
              <el-input v-model="formEvent.form.zlj"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="电源" prop="dy">
              <el-input v-model="formEvent.form.dy"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="机组重量(kg)" prop="jzzl">
              <el-input v-model="formEvent.form.jzzl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="充注量(kg)" prop="czl">
              <el-input v-model="formEvent.form.czl"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="外形尺寸" prop="wxcc">
              <el-input v-model="formEvent.form.wxcc"></el-input>
            </el-form-item>
          </el-col>
        </div>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="启用/停用">
            <el-select v-model="formEvent.form.sfqy">
              <el-option label="启用" value="1"></el-option>
              <el-option label="停用" value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="创建人" prop="cjr">
            <el-input v-model="formEvent.form.cjr" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
          <el-form-item label="创建时间" prop="cjtime">
            <el-input v-model="formEvent.form.cjtime" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="16" style="margin-left:20px">

        <div style="margin-bottom: 20px;">
          <el-image style="width: 175px; height: 210px;display: block;" :src="computedPhoto" alt="暂无图片"
                    :preview-src-list="sbzpList">
            <div slot="error" class="imageError">
              <span>暂无图片</span>
            </div>
          </el-image>

          <div class="sbtext">设备图片</div>

        </div>
        <div v-if="showEwm && formEvent.form.ewm==='1'">
          <el-image style="width: 175px; height: 210px;display: block;" :src="src" alt="暂无图片">
            <div slot="error" class="imageError">
              <span>暂无图片</span>
            </div>
          </el-image>
          <div class="sbtext">二维码图片</div>
        </div>
      </el-row>
    </div>

    <!-- 主键是不可以编辑的，不可查看�? -->
    <el-input v-model="formEvent.form.sbbm" v-show="false"></el-input>
    <el-row v-if="formEvent.type === 'view' ? false : true" :gutter="10">
      <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
        <el-form-item class="tool-button-container">
          <el-button
            @click="closeEvent()"
            :size="size"
            icon="fa fa-minus-square-o"
          >
            取消
          </el-button
          >
          <el-button
            type="primary"
            @click="submitEvent()"
            :size="size"
            icon="fa fa-save (alias)"
          >
            确定
          </el-button
          >
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import {CommonApi} from '@/api/equip/CommonApi.js'
import {FormEvent} from "../model/accountQuery-form.js";
import {GridEvent} from '../model/accountQuery-table'
import {reactive} from "vue";
import {accountQueryApi} from '@/api/equip/accountQueryApi.js'
import {warehouseManagement} from '@/api/equip/warehouseManagement.js'
import {generateQRCode} from '@/api/equip/generateQRCode.js'
import {getInfo} from "@/api/login";
import {parseTime} from "@/utils/ruoyi";

export default {
  name: "equipmentMaintenanceForm",
  props: {
    formData: {
      type: Object,
    },
  },
  data() {
    let GLOBAL_URL = {
      CDN_URL: process.env.VUE_APP_CDN_URL,
      UDS_URL: process.env.VUE_APP_UDS_URL,
    }
    return {
      imageURL: GLOBAL_URL.CDN_URL + "/cdn/zzgd-img/",
      udsImageUrl: GLOBAL_URL.UDS_URL + "/FileController/downFile/",
      file_list: [],
      size: "small",
      formEvent: reactive(FormEvent),
      formData: {
        cjr: 'admin',
        cjtiime: new Date() + ''
      },
      rules: reactive(FormEvent).rules,
      // OptionData:formEvent.OptionData
      OptionData: {
        OptionData_yxzt: GridEvent.OptionData_yxzt,
        OptionData_sblxmc: [],
        OptionData_gldw: GridEvent.OptionData_gldw,
        // OptionData_ssnyzmc:GridEvent.OptionData_ssnyzmc,
        OptionData_jlfs: GridEvent.OptionData_jlfs,
        OptionData_sskfmc: []
      },
      src: '',
      showEwm: true,
      sbzpList: []
    };
  },
  mounted() {
    this.formEvent.initFormData(this.formData);
    if (this.formEvent.type === 'insert') {
      getInfo().then(res => {
        this.formEvent.form.cjr = res.user.nickName
        this.formEvent.form.cjtime = parseTime(new Date())
      })
    }
    this.OptionData_sblxmc(this.formEvent.form.wzlbbm)
    if (this.formEvent.form.gldwbm) {
      warehouseManagement.getKfByGldw(this.formEvent.form.gldwbm).then(res => {
        this.OptionData.OptionData_sskfmc = []
        res.data.forEach((item) => {
          this.OptionData.OptionData_sskfmc.push({
            label: item.kfName, value: item.id
          })
        })
      }).catch(err => {
      })
    }
    if (this.formEvent.form.wzlbbm === '2000') {
      this.showEwm = false
    } else {
      this.showEwm = true
      if (this.formEvent.form.ewm === '1') {
        this.getEwmData(this.formEvent.form)
      }
    }
  },
  computed: {
    computedPhoto() {
      if (this.formEvent.form.sbzp && this.formEvent.form.sbzp.length > 10) {
        this.sbzpList = []
        if (this.formEvent.form.sbzp.startsWith("https")) {
          this.sbzpList.push(this.formEvent.form.sbzp)
          return this.formEvent.form.sbzp;
        } else {
          this.sbzpList.push(this.udsImageUrl + this.formEvent.form.sbzp + "/user.png")
          return this.udsImageUrl + this.formEvent.form.sbzp + "/user.png"

        }
      }
      // return this.imageURL+'photoDefault.png'
    }
  },
  methods: {
    getEwmData(row) {
      generateQRCode.getEwmData(row.sbbm).then(res => {
        this.src = res.data[0].ewm
      }).catch(err => {
        console.log(err)
      })
    },
    OptionData_sblxmc(wzlbbm) {
      accountQueryApi.queryDictDatasb(wzlbbm).then(res => {
        res.data.forEach((item) => {
          this.OptionData.OptionData_sblxmc.push({
            label: item.name, value: item.id
          })
        })

      }).catch(err => {

      })


    },
    allowUpload(file) {  //判断是否允许上传
      return new Promise((resolve, reject) => {

        const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/bmp' || file.type === 'image/jpg' || file.type === 'image/gif';
        if (!isJpgOrPng) {
          this.$message.error('非图片格式：jpeg/png/bmp/jpg/gif');
          return reject(false);
        }
        return resolve(true) //如没有问题了那咱们就通过resolve函数添加一个true 让文件上传

      })
    },
    updatePhoto(file, fileList) {
      this.file_list = fileList
      var formData = new FormData();
      formData.append("file", file.raw);
      formData.append("fileId", this.formEvent.form.sbbm);
      formData.append("p_id", this.formEvent.form.sbbm);
      formData.append("user_name", "system");
      formData.append("table_name", "en_equip.t_en_wz_equip");
      // formData.append("table_name","en_equip-t_en_wz_equip");
      formData.append("col_name", "sbzp");
      formData.append("bizcType", "0");
      CommonApi.uploadImage(formData).then(res => {
        if (res) {
          this.formEvent.form.sbzp = res.data.url;
        }
      }).catch(err => {
        console.log(err)
      })
    },
    handleChange(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} file upload failed.`);
      }
    },
    onchange_sskf(val) {
      this.formEvent.form.sskfmc = ''
      if (val) {
        let arr = this.OptionData.OptionData_sskfmc.filter(item => {
          return item.value == val;
        })
        if (arr && arr.length > 0) {
          this.formEvent.form.sskfmc = arr[0].label;
        }
      }
    },
    onchange_yxzt(val) {

      this.formEvent.form.yxztmc = ''
      //  debugger
      if (val) {
        let arr = this.OptionData.OptionData_yxzt.filter(item => {
          return item.value == val;
        })
        if (arr && arr.length > 0) {
          this.formEvent.form.yxztmc = arr[0].label;
        }
      }
    },
    onchange_jlfs(val) {
      this.formEvent.form.jlfsmc = ''
      //  debugger
      if (val) {
        let arr = this.OptionData.OptionData_jlfs.filter(item => {
          return item.value == val;
        })
        if (arr && arr.length > 0) {
          this.formEvent.form.jlfsmc = arr[0].label;
        }
      }
    },
    onchange_sblx(val) {

      this.formEvent.form.sblxmc = ''
      //  debugger
      if (val) {
        let arr = this.OptionData.OptionData_sblxmc.filter(item => {
          return item.value == val;
        })
        if (arr && arr.length > 0) {
          this.formEvent.form.sblxmc = arr[0].label;
        }
      }
    },
    onchange_gldw(val) {
      console.log(val)
      this.formEvent.form.gldwmc = ''
      // debugger
      if (val) {
        let arr = this.OptionData.OptionData_gldw.filter(item => {
          return item.value == val;
        })
        if (arr && arr.length > 0) {
          this.formEvent.form.gldwmc = arr[0].label;
        }
        warehouseManagement.getKfByGldw(val).then(res => {
          this.OptionData.OptionData_sskfmc = []
          res.data.forEach((item) => {
            this.OptionData.OptionData_sskfmc.push({
              label: item.kfName, value: item.id
            })
          })
        }).catch(err => {

        })
      }
    },
    // 移除图片
    photoRemove(file, fileList) {
      // this.photoHide = false;
      this.file_list = []
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    closeEvent() {
      //关闭窗口事件,不刷�?//
      this.$emit("closeEvent", false);
    },
    submitEvent() {
      //关闭窗口事件,刷新表格数据//
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.formEvent
            .saveFormData()
            .then((res) => {
              this.$emit("closeEvent", true);
              this.$message.success("保存成功!");
            })
            .catch((err) => {
              this.$message.warning("请确认出厂编码是否重复");
              console.error(err);
            });
        } else {
          return false;
        }
      });

    },
  },
};
</script>
<style>
.styleA .el-upload--text {
  width: 130px;
  height: 180px;
  line-height: 180px;
}

.styleB .el-upload--text {
  display: none;
}
</style>
<style scoped>
/deep/ .imageError {
  text-align: center;
  width: 160px;
  height: 100px;
  line-height: 100px;
  color: #606266;
}

.sbtext {
  width: 175px;
  height: 25px;
  line-height: 27px;
  background: #0e867f;
  text-align: center;
  color: #fff;
  margin-top: 5px;
}

.tool-button-container {
  text-align: right;
}

.el-select {
  width: 100% !important
}

>>> .el-upload {
  width: 180px;
  height: 200px;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  line-height: 200px;
  text-align: center;
  font-size: 28px;
}

>>> .el-upload:hover {
  border-color: #409EFF;
}

>>> .avatar-uploader-icon {

  color: #8c939d;
  width: 178px;
  height: 178px;

}

>>> .avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.el-upload-list__item-thumbnail {
  width: 180px;
  height: 200px;
}
</style>
